﻿
CREATE PROCEDURE [dbo].[resuma_GetProcentGrila]
	-- Add the parameters for the stored procedure here
	@IDAngajatSalarizare int,
	@IDTipSpor int,
	@Procent decimal(6,2) out
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	DECLARE @Vechime decimal(18,3)

	SET @Procent = 0
    -- Insert statements for procedure here
	SELECT  @Vechime = a.VechimeSporAni*12 + a.VechimeSporLuni FROM [AngajatiSalarizare] a WHERE a.IDAngajatSalarizare = @IDAngajatSalarizare
	
	SELECT @Procent=Valoare FROM  Grile gr
		WHERE gr.IDTipSpor = @IDTipSpor AND 
		@Vechime >= gr.Minim*12 AND @vechime < gr.Maxim*12
END